package edu.sctu.jarime.may.day20150517;

/**
 * Created by user19 on 2015/5/18.
 */
public class TextMore {
    protected TeaCher[] teacher;

    public TextMore(TeaCher[] teacher) {

        this.teacher = teacher;
    }

    /***
     * 对老师学号进行排序
     */
    public TeaCher[] sortNumber() {
        TeaCher[] teacherA = new TeaCher[teacher.length];

        teacherA = teacher;
        TeaCher teaCher = new TeaCher();
        for (int i = 0; i < teacherA.length; i++) {
            for (int j = 0; j < teacherA.length-1; j++)
                if (teacherA[j+1].number < teacherA[j].number) {
                    teaCher = teacherA[j];
                    teacherA[j] = teacherA[j -1];
                    teacherA[j -1] = teaCher;
                }
        }
        return teacherA;
    }

    /***
     *对老师所教学生成绩进行排序
     *
     * @param student
     */

    public void sortStudent(Student[] student) {
        Student[] teacherA = new Student[student.length];
        for (int i = 0; i < (student.length - 1); i++) {
            for (int j = 0; j < (student.length - 1); j++) {
                if (student[j].score > student[j + 1].score) {
                    teacherA[0] = student[j];
                    student[j] = student[j + 1];
                    student[j + 1] = teacherA[0];
                }
            }
        }
    }

    /***
     *对老师职称为教授的进行返回
     * @return
     */
    public TeaCher pritCoded() {
        TeaCher returnTeacher = null;
        for (TeaCher teacher : this.teacher) {
            if (teacher.work.equals("教授")) {
                returnTeacher = teacher;
            }
        }
        return returnTeacher;
    }

}
